package com.ojoin.trade.common_core.web.domain;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.hibernate.validator.constraints.NotBlank;
import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.ojoin.trade.common.web.domain.IDentifiable;
import com.ojoin.trade.common.web.domain.Pair;

@JsonIgnoreProperties(ignoreUnknown = true)
public class TbMerchantInfo implements IDentifiable {
    private Integer id;
    
	private Integer idOfTbMerchantUser;

    private String doctype;//三证，五证

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")  
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date rowUpdateTime;

    private Date rowCreateTime;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }


    public void setDoctype(String doctype) {
        this.doctype = doctype;
    }

    private String address;
    
    public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	@Override
    public Date getRowUpdateTime() {
        return rowUpdateTime;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void setRowUpdateTime(Date rowUpdateTime) {
        this.rowUpdateTime=rowUpdateTime;
    }

    @Override
    public Date getRowCreateTime() {
        return rowCreateTime;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public void setRowCreateTime(Date rowCreateTime) {
        this.rowCreateTime=rowCreateTime;
    }

    @Override
    public String getTableName() {
        return "tb_merchant_info";  //To change body of implemented methods use File | Settings | File Templates.
    }

    public Integer getIdOfTbMerchantUser() {
        return idOfTbMerchantUser;
    }

    public void setIdOfTbMerchantUser(Integer idOfTbMerchantUser) {
        this.idOfTbMerchantUser = idOfTbMerchantUser;
    }

    public List<Pair> valid(){
    	List<Pair> error=new ArrayList<Pair>();
    	if("5".equals(this.doctype)){
    		if(StringUtils.isEmpty(this.getTaxNo())){
    			error.add(Pair.of("taxNo","税务登记证不能为空"));
    		}
    		
			if(StringUtils.isEmpty(this.getOrgNo())){
				error.add(Pair.of("orgNo","组织机构代码证不能为空"));
			}
			
			if(StringUtils.isEmpty(this.getSwdjz())){
				error.add(Pair.of("swdjz","税务登记证原件图片没有上传"));
			}
			
			if(StringUtils.isEmpty(this.getZzjgdm())){
				error.add(Pair.of("zzjgdm","组织机构代码证原件图片没有上传"));
			}
    	}
    	
    	return error;
    }
	 
	//登录账号
	private String loginNo;
	/**
	 * 认证状态 
	 * "0","初始化"，"1","审批中"，"2","审核通过"，"3","审核未通过"
	 */
	private String realStatus;
	
	private String realNameStatus;
	
	/**
	 * 是否实名通过
	 * @return
	 */
	public boolean isRealNameStatusOK(){
		return StringUtils.isNotEmpty(realStatus)&&("1".endsWith(realStatus)||"2".equals(realStatus));
	}
	
	//余额开户状态 AC00=已开户 AC01=未开户
	private String accStatus;
	
	private String  accNameStatus;

	//新版对应旧版np
	private String npaccAccStatus;

	private String npaccNameStatus;


	/**
	 * 是否设置过初始密码
	 * true未设置初始支付密码
	 * false已设置初始支付密码
	 */
	private String payPasswdIsNuLL;
	
	//驳回原因
	private String memo;
	
	//基本户账号
	private String bankAccount;
	
	private String mhtNo;
	private String mchType;
	
	@NotBlank(message="工商注册名称不能为空")
	private String mchName;
	
	@NotBlank(message="商户手机号不能为空")
	private String mobile;
	
	@NotBlank(message="法人姓名不能为空")
	private String name;
	
	@NotBlank(message="法人身份证号不能为空")
	private String certNo;
	
	@NotBlank(message="营业执照号不能为空")
	private String licNo;
	
	private String taxNo;
	
	@NotBlank(message="法人身份证有效期不能为空")
	private String certDate;
	
	@NotBlank(message="开户许可证不能为空")
	private String openNo;
	
	private String orgNo;
	
	@NotBlank(message="银行预留手机号(大额交易)不能为空")
	private String cardMobile;
	
	//对公账号
	@NotBlank(message="企业账号不能为空")
	private String cardNo;
	
	private String cardProvince;
	private String cardCity;
	
	private String displayBranchNo;
	public String getDisplayBranchNo() {
		return displayBranchNo;
	}
	public void setDisplayBranchNo(String displayBranchNo) {
		this.displayBranchNo = displayBranchNo;
	}
	
	@NotBlank(message="开户行不能为空")
	private String branchNo;
	
	public String getPayPasswdIsNuLL() {
		return payPasswdIsNuLL;
	}
	public void setPayPasswdIsNuLL(String payPasswdIsNuLL) {
		this.payPasswdIsNuLL = payPasswdIsNuLL;
	}
	 
	public String getLoginNo() {
		return loginNo;
	}
	public void setLoginNo(String loginNo) {
		this.loginNo = loginNo;
	}
	public String getRealStatus() {
		return realStatus;
	}
	public void setRealStatus(String realStatus) {
		this.realStatus = realStatus;
	}
	public String getMemo() {
		return memo;
	}
	public void setMemo(String memo) {
		this.memo = memo;
	}
	//个人
	//身份证反面
	private String cardBack;
	//身份证正面
	private String cardObverse;
	
	public String getCardBack() {
		return cardBack;
	}
	public void setCardBack(String cardBack) {
		this.cardBack = cardBack;
	}
	public String getCardObverse() {
		return cardObverse;
	}
	public void setCardObverse(String cardObverse) {
		this.cardObverse = cardObverse;
	}
	//企业
	//法人身份证
	@NotBlank(message="法人身份证没有上传")
	private String frsfz;
	//营业执照
	@NotBlank(message="营业执照图片没有上传")
	private String yyzz;
	//税务登记证 
	private String swdjz;
	//组织机构代码证
	private String zzjgdm;
	//开户回执单
	private String khhzd;
	//开户许可证
	@NotBlank(message="开户许可证没有上传")
	private String khxkz;
	
	
	public String getFrsfz() {
		return frsfz;
	}
	public void setFrsfz(String frsfz) {
		this.frsfz = frsfz;
	}
	public String getKhhzd() {
		return khhzd;
	}
	public void setKhhzd(String khhzd) {
		this.khhzd = khhzd;
	}
	public String getKhxkz() {
		return khxkz;
	}
	public void setKhxkz(String khxkz) {
		this.khxkz = khxkz;
	}
	public String getSwdjz() {
		return swdjz;
	}
	public void setSwdjz(String swdjz) {
		this.swdjz = swdjz;
	}
	public String getYyzz() {
		return yyzz;
	}
	public void setYyzz(String yyzz) {
		this.yyzz = yyzz;
	}
	public String getZzjgdm() {
		return zzjgdm;
	}
	public void setZzjgdm(String zzjgdm) {
		this.zzjgdm = zzjgdm;
	}
	
	public String getMhtNo() {
		return mhtNo;
	}
	public void setMhtNo(String mhtNo) {
		this.mhtNo = mhtNo;
	}
	public String getMchType() {
		return mchType;
	}
	public void setMchType(String mchType) {
		this.mchType = mchType;
	}
	public String getMchName() {
		return mchName;
	}
	public void setMchName(String mchName) {
		this.mchName = mchName;
	}
	public String getMobile() {
		return mobile;
	}
	public void setMobile(String mobile) {
		this.mobile = mobile;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getCertNo() {
		return certNo;
	}
	public void setCertNo(String certNo) {
		this.certNo = certNo;
	}
	public String getLicNo() {
		return licNo;
	}
	public void setLicNo(String licNo) {
		this.licNo = licNo;
	}
	public String getTaxNo() {
		return taxNo;
	}
	public void setTaxNo(String taxNo) {
		this.taxNo = taxNo;
	}
	public String getCertDate() {
		return certDate;
	}
	public void setCertDate(String certDate) {
		this.certDate = certDate;
	}
	public String getOpenNo() {
		return openNo;
	}
	public void setOpenNo(String openNo) {
		this.openNo = openNo;
	}
	public String getOrgNo() {
		return orgNo;
	}
	public void setOrgNo(String orgNo) {
		this.orgNo = orgNo;
	}
	public String getCardMobile() {
		return cardMobile;
	}
	public void setCardMobile(String cardMobile) {
		this.cardMobile = cardMobile;
	}
	public String getCardNo() {
		return cardNo;
	}
	public void setCardNo(String cardNo) {
		this.cardNo = cardNo;
	}
	public String getCardProvince() {
		return cardProvince;
	}
	public void setCardProvince(String cardProvince) {
		this.cardProvince = cardProvince;
	}
	public String getCardCity() {
		return cardCity;
	}
	public void setCardCity(String cardCity) {
		this.cardCity = cardCity;
	}
	public String getBranchNo() {
		return branchNo;
	}
	public void setBranchNo(String branchNo) {
		this.branchNo = branchNo;
	}
	
	public String getBankAccount() {
		return bankAccount;
	}
	public void setBankAccount(String bankAccount) {
		this.bankAccount = bankAccount;
	}
	

	public void setAccStatus(String accStatus) {
		this.accStatus = accStatus;
	}
	
	public String getRealNameStatus() {
		return realNameStatus;
	}
	public void setRealNameStatus(String realNameStatus) {
		this.realNameStatus = realNameStatus;
	}
	public void setAccNameStatus(String accNameStatus) {
		this.accNameStatus = accNameStatus;
	}

	public String getAccNameStatus() {
		if(StringUtils.isNotEmpty(npaccNameStatus)){
			return npaccNameStatus;
		}
		return accNameStatus;
	}

	public String getAccStatus() {
		if(StringUtils.isNotEmpty(npaccAccStatus)){
			return npaccAccStatus;
		}
		return accStatus;
	}

	public void setNpaccAccStatus(String npaccAccStatus) {
		this.npaccAccStatus = npaccAccStatus;
	}

	public void setNpaccNameStatus(String npaccNameStatus) {
		this.npaccNameStatus = npaccNameStatus;
	}
	/**
	 * 营业执照不为空，税务登记证==组织机构代码证
	 * @return
	 */
	public String getDoctype() {
		if(null==doctype){
			if(StringUtils.isNotEmpty(this.yyzz)&&StringUtils.isNotEmpty(this.swdjz)&&this.swdjz.equals(this.zzjgdm)){
				return "3";
			}else{
				return "5";
			}
		}
		return doctype;
	}
	
	public void formateDate(){
		if(this.certDate!=null&&this.certDate.length()==8){
			String formateDate=this.certDate.substring(0,4)+"-"+this.certDate.substring(4,6)+"-"+this.certDate.substring(6,8);
			this.setCertDate(formateDate);
		}
	}
}